package com.sq.partner.manager.dao.impl;


import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.sq.partner.manager.common.exception.AppException;
import com.sq.partner.manager.dao.IGatewayAgentInfoMtDao;
import com.sq.partner.manager.dao.IGatewayPolicyProtocolDao;
import com.sq.partner.manager.mybatis.model.GatewayUser;
import com.sq.partner.manager.mybatis.model.TradAgentInfo;
import com.sq.partner.manager.util.LogUtil;
import com.sq.partner.manager.util.Page;



@Repository
public class GatewayPolicyProtocolDaoImpl extends BaseDaoImpl implements IGatewayPolicyProtocolDao {
	
	private static Logger logger = LogUtil.getLog(GatewayPolicyProtocolDaoImpl.class);
	
	@Resource
	private IGatewayAgentInfoMtDao agentInfoMtDao;
	//条件分页查询车捷保保单
	@Override
	public Page<Map<String,Object>> queryProtocolPolicyPageByCriteria(Page page) throws Exception {
		Map<String,Object> map = (Map<String, Object>) page.getType();
		//条件查询总条数
		int count=(Integer) query("queryCountPolicyProtocol",map );
		page.setTotal(count);
		page.setData((List<Map<String, Object>>) queryList("queryPolicyProtocolByPage", map));
		return page;
	}
	//下载电子保单查询
	@Override
	public List<Map<String, Object>> queryProtocolPolicyListByCriteria(
			Map<String, Object> map) throws Exception {
		List<Map<String, Object>> protocolPolicyList = queryList("queryPolicyListOfProtocolByMap", map);
		return protocolPolicyList;
	}
	//根据保单号查询保单信息
	@Override
	public Map<String, Object> queryProtocolById(String polno) throws Exception {
		return (Map<String,Object>)query("queryProtocolById",polno);
	}
	//编辑保单
	@Override
	public void saveUpProtocol(Map<String, Object> map) throws Exception {
		// TODO Auto-generated method stub
		update("saveUpProtocol",map);
	}
	//批量更新实收状态
	@Override
	public Map<String, Integer> batchUpdate(List<Map<String, Object>> lists) throws Exception {
		//更新成功数
		int success = 0;
		//更新失败数
		int error = 0;
		//进行批量更新
		Map<String,Object> map = new HashMap<String,Object>();
		for(int i=0;i<lists.size();i++){
			success++;
			map=lists.get(i);
			update("saveUpProtocol",map);
		}
		
		Map<String,Integer> resultMap = new HashMap<String, Integer>();
		resultMap.put("success", success);
		resultMap.put("error", error);
		
		return resultMap;
	}
	//查询保单号验证
	@Override
	public List<String> queryPolno(String polnos) throws Exception {
		// TODO Auto-generated method stub
		return (List<String>)queryList("queryPolno",polnos);
	}
	
	
	
	
}
	 



















	 

 
